<?php 

class HotelDateGroup extends CActiveRecord
{
	public function tableName()
	{
		return lfirst(__CLASS__);
	}
	
	public static function model($className = __CLASS__)
    {
    	return parent::model(lfirst(__CLASS__));
    }
    
	public function relations()
	{
		return array(
			'hotelDates'	  => array(self::HAS_MANY, 'HotelDate', 'hotelDateGroupId', 'order'=>'??.id asc'),
	    );
	}
	
	public function criteria($sort = 'hotelDateGroup.id', $order = 'asc')
	{
		$params['order'] = $sort . ' ' . $order;
    	
		$this->getDbCriteria()->mergeWith($params);
    	
    	return $this;
	}
}